/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package server.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Comparator;

/**
 *
 * @author fillipe
 */
public class Product implements Serializable {

    private Long id;
    private String description;
    private BigDecimal price;
    private Integer stock;

    public Product() {
    }
    
   public Product(Long id) {
        this.id = id;
    }

    public Product(String description, BigDecimal price, Integer stock) {
        this.description = description;
        this.price = price;
        this.stock = stock;
    }
    
    public Product(String description, BigDecimal price, Integer stock, Long id) {
        this.description = description;
        this.price = price;
        this.stock = stock;
        this.id = id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public Long getId() {
        return id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public BigDecimal getPrice() {
        return price;
    }

    public void setPrice(BigDecimal price) {
        this.price = price;
    }

    public Integer getStock() {
        return stock;
    }

    public void setStock(Integer stock) {
        this.stock = stock;
    }

    @Override
    public String toString() {
        return "Product{" + "id=" + id + ", description=" + description + ", price=" + price + ", stock=" + stock + '}';
    }

    public static Comparator getDescriptionComparator() {
        return new Comparator<Product>() {

            @Override
            public int compare(Product a, Product b) {
                return a.getDescription().compareToIgnoreCase(b.getDescription());
            }
        };
    }
}
